//
//  PhoneParamRequset.m
//  BUS365
//
//  Created by login on 15-10-28.
//  Copyright (c) 2015年 bus365. All rights reserved.
//

#import "PhoneParamRequset.h"
#import "PhoneParamModel.h"
@implementation PhoneParamRequset
+ (void)getRequestWithAndResult:(void(^)(NSArray *resultArray))block AndFail:(void(^)(NSString *error))failBlock
{
    NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
    [dict setObject:@"202" forKey:@"code"];

    [RequestHttpTool AFNManagerGet:PhoneParamInterFace params:dict success:^(id responseObj) {
        
        NSArray *array = [NSJSONSerialization JSONObjectWithData:responseObj options:NSJSONReadingMutableContainers error:nil];
        NSString *contentString = array[0][@"description"];
        NSString *current = [contentString stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
        NSData *data = [current dataUsingEncoding:NSUTF8StringEncoding];
        NSArray *contentArray = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
        NSMutableArray *resultArray = [[NSMutableArray alloc]init];
        for(NSDictionary *dic in contentArray)
        {
            PhoneParamModel *model = [[PhoneParamModel alloc]initWithDictionary:dic error:nil];
            [resultArray addObject:model];
        }
        block(resultArray);
        
    } failure:^(NSError *error, id responseObj) {
        if (responseObj) {
            failBlock(@"服务器异常!");
        }else
        {
            failBlock(NetWorkError);
        }
    }];
    
}
@end
